<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title></title>
					<script type="text/javascript">
						var ajaxdata="{{U('goods/ajaxdata')}}"
					</script>
	<link rel="stylesheet" href="Public/Admin/css/bootstrap.min.css" />
	<link rel="stylesheet" href="Public/Admin/css/common.css" />
	<script type="text/javascript" src='Public/Admin/js/jquery-1.8.2.min.js'></script>	
	<!--多图上传-->	
    <script type="text/javascript" src="Public/uploadify/jquery.uploadify.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Public/uploadify/uploadify.css">
	<script type="text/javascript" src="Public/Admin/js/goodajax.js"></script>
    		
    	
	
	<!--载入百度编辑器-->
	    	<script type="text/javascript" charset="utf-8" src="Public/ueditor/ueditor.config.js"></script>
    		<script type="text/javascript" charset="utf-8" src="Public/ueditor/ueditor.all.min.js"> </script>
    		<script type="text/javascript" charset="utf-8" src="Public/ueditor/lang/zh-cn/zh-cn.js"></script>
    	
	<!--<script type="text/javascript">
		var root = '__ROOT__';
		//图片上传提交地址
		var handler = '{:U("uploadEditor")}';
		var uploadify_path = '__UPLOADIFY__';
		var sess_name = "<?php echo session_name(); ?>";
		var sess_id = "<?php echo session_id(); ?>";
		//列表图上传地址
		var pic_uploader = '{:U("uploadPic")}';
		//商品图册上传地址
		var photo_uploader = '{:U("uploadPhoto")}';
		var upload_path = '__UPLOAD__';
		var delPic = '{:U("delPic")}';
		var getAttr = '{:U("getAttr")}';
	</script>-->
	<style type="text/css">
		#uploadList,#uploadList2{
			width: 640px;
		}
		#uploadList img,#uploadList2 img{
			width: 100px;
			height: 50px;
			/*overflow: hidden;*/
		}
		#uploadList ul li{
			border: 1px solid #ccc;
			float: left;
			margin-left: 3px;
		}
		#uploadList2 ul li{
			border: 1px solid #ccc;
			float: left;
			margin-left: 3px;
		}
	</style>
	<!--点击按钮百度输入框的显影-->
	<script type="text/javascript">
		$(function(){
			var c=0;
			$('.bh1').click(function(){
				if(c==0){
					$(this).parent().siblings().show(500);
					c=1;
				}else{
					$(this).parent().siblings().hide(500);
					c=0;
				}
				
			})
			var b=0;
			$('.bh2').click(function(){
				if(b==0){
					$(this).parent().siblings().show(500);
					b=1;
				}else{
					$(this).parent().siblings().hide(500);
					b=0;
				}
				
			})
		})
	</script>
</head>
<body>

<div lab="uploadFile">
    <script type="text/javascript">
        $(function() {
            $('#f').uploadify({
                'formData'     : {//POST数据
                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
                },
                'fileTypeDesc' : '上传文件',//上传描述
                'fileTypeExts' : '*.jpg;*.png',
                'swf'      : '{{__PUBLIC__}}/uploadify/uploadify.swf',
                'uploader' : '{{U('upload')}}',
                'buttonText':'选择文件',
                'fileSizeLimit' : '6000KB',
                'uploadLimit' : 1,//上传文件数
                'width':65,
                'height':25,
                'successTimeout':10,//等待服务器响应时间
                'removeTimeout' : 0.2,//成功显示时间
                'onUploadSuccess' : function(file, data, response) {
                    //转为json
                    data=$.parseJSON(data);
                    //获得图片地址
                    var imageUrl = data.url;
                    var li="<li><img src='"+imageUrl+"'/><input class='btn btn-info btn-danger shanchu'  type='button' value='删除' /><input type='hidden' name='listimg' value='"+data.path+"'/></li>";
                    $("#uploadList ul").prepend(li);
                }
            });
            // 多照片上传
            $('#s').uploadify({
                'formData'     : {//POST数据
                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
                },
                'fileTypeDesc' : '上传文件',//上传描述
                'fileTypeExts' : '*.jpg;*.png',
                'swf'      : '{{__PUBLIC__}}/uploadify/uploadify.swf',
                'uploader' : '{{U('uploads')}}',
                'buttonText':'选择文件',
                'fileSizeLimit' : '6000KB',
                'uploadLimit' : 10,//上传文件数
                'width':65,
                'height':25,
                'successTimeout':10,//等待服务器响应时间
                'removeTimeout' : 0.2,//成功显示时间
                'onUploadSuccess' : function(file, data, response) {
                    //转为json
                    data=$.parseJSON(data);
                    //获得图片地址
                    var imageUrl = data.url;
                    var li="<li><img src='"+imageUrl+"'/><input class='btn btn-info btn-danger shanchu'  type='button' value='删除' /><input type='hidden' name='gdimg[]' value='"+data.path+"'/></li>";
                    $("#uploadList2 ul").prepend(li);
                }
            });
            
        });
    </script>

</div>	

	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">

	<form action="" method='post'>
		<fieldset>
			<legend>修改商品</legend>
			<table class='table table-bordered table-hover'>
				<thead>
					<tr>
						<th colspan="2" class="btn btn-primary">基本信息</th>
					</tr>

				</thead>
				<tbody>
			
					<tr class="info">
						<td>所属分类</td>
						<td>
							<select name="cate_id">
								<option value="0">-请选择-</option>
									{{foreach from="$oldgcateData" value='$v'}}
									<option {{if value="$oldgoodData['cate_id']==$v['gcid']"}}selected{{endif}} value="{{$v['gcid']}}" tid="{{$v['form_fid']}}">{{$v['_name']}}</option>
						
									{{endforeach}}
									
							</select>
							<input type="hidden" name="form_fid" value="{{$oldgoodData['form_fid']}}" />
						</td>
					</tr>
					<tr class="info">
						<td>所属品牌</td>
						<td>
							<select name="brand_bid">
								<option value="0">-请选择-</option>
								
									{{foreach from="$oldbrandData" value='$v'}}
									<option {{if value="$oldgoodData['brand_bid']==$v['bid']"}}selected{{endif}} value="{{$v['bid']}}">{{$v['bname']}}</option>
									{{endforeach}}
								
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>商品名称</td>
						<td>
							<input value="{{$oldgoodData['gname']}}" type="text" name='gname'/>
						</td>
					</tr>
					<tr class="info">
						<td>单位</td>
						<td>
							<input type="text" name='unit' value="{{$oldgoodData['unit']}}"/>
						</td>
					</tr>
					<tr class="info">
						<td>市价场</td>
						<td>
							<input type="text" name='marketprice' value="{{$oldgoodData['marketprice']}}"/>
						</td>
					</tr>
					<tr class="info">
						<td>商城价</td>
						<td>
							<input type="text" name='shopprice' value="{{$oldgoodData['shopprice']}}"/>
						</td>
					</tr>
					<tr class="info">
						<td>库存</td>
						<td>
							<input type="text" name='stock' value="{{$oldgoodData['stock']}}"/>
						</td>
					</tr>
					<tr class="info">
						<td>点击次数</td>
						<td>
							<input type="text" name='click' value="{{$oldgoodData['click']}}"/>
						</td>
					</tr>
					<tr class="info">
						<td>排序</td>
						<td>
							<input type="text" name='gsort' value="{{$oldgoodData['gsort']}}"/>
						</td>
					</tr>
						
				</tbody>
			</table>

			<p class="btn btn-primary">商品属性</p>
			<!--异步添加部分-->
			
			<table class="table table-bordered table-hover" id='attr' class="info">
				<tr></tr>
				{{if value="!empty($gsattr[0])"}}
				{{foreach from="$gsattr[0]" value='$v'}}
				<tr>
					<td>{{$v['taname']}}</td>
					<td>
						<select name="attr[{{$v['taid']}}]">
							<option value="0">请选择</option>
							{{foreach from="$v['tavalue']" value="$vv"}}
							<option {{if value="$v['gavalue']==$vv"}}selected{{endif}} value="{{$vv}}">{{$vv}}</option>
							{{endforeach}}
						</select>	
					</td>
				</tr>
				{{endforeach}}
				{{endif}}
			</table>
			
			<!--异步添加部分结束-->
			<p class="btn btn-primary">商品规格</p>
			<table class="table table-bordered table-hover" id='spec'>
				<tr></tr>		
				{{if value="!empty($gsattr[1])"}}
				{{foreach from="$gsattr[1]" key='$k' value='$v'}}
				<tr>
					<td>{{$v['taname']}}</td>
					<td>
						<select name="spec[{{$v['taid']}}][value][]">
							<option value="0">请选择</option>
							{{foreach from="$v['tavalue']" value="$vv"}}
							<option {{if value="$v['gavalue']==$vv"}}selected{{endif}} value="{{$vv}}">{{$vv}}</option>
							{{endforeach}}
						</select>						
					</td>
					<td>附加价格</td>
					<td><input type="text" name="spec[{{$v['taid']}}][price][]" id="" value="{{$v['gaadd']}}" /></td>
					<td>添加规格</td>
					<td>
						<input class="btn btn-info add-spec"  type="button" value="添加规格" />
					</td>
				</tr>
				{{endforeach}}				
				{{endif}}
			</table>

			<table class='table table-bordered'>
				<tr>
					<th colspan="3" class="btn btn-primary">列表图</th>
				</tr>
				<tr  class="info">
					<td width="100">上传图片</td>
					<td width="300">
						   <input id="f" type="file" multiple="true">
    						<span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
					</td>
					<td  id='uploadList'>												      
						<ul>
							<li>
								{{if value="!empty($oldgoodData['listimg'])"}}
								<img src="{{$oldgoodData['listimg']}}" alt="" /><input class="btn btn-info btn-danger shanchu"  type="button" value="删除" />
								<input type="hidden" name="listimg" value="{{$oldgoodData['listimg']}}"/>
								{{endif}}
							</li>
						</ul>							 
					</td>
				</tr>
			</table>

			<table class='table table-bordered'>
				<tr>
					<th colspan="3" class="btn btn-primary">商品图册</th>
				</tr>
				<tr class="info">
					<td width="100">上传图片</td>
					<td width="300">
						<input id="s" type="file" multiple="true">
    					<span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
					</td>
					<td id='uploadList2'>
						<ul>
							{{foreach from="$oldgdetail['gdimg']" value="$v"}}
							<li>
								<img src="{{$v}}" alt="" /><input class="btn btn-info btn-danger shanchu"  type="button" value="删除" />
								<input type="hidden" name="gdimg[]" value="{{$v}}"/>
							</li>
							{{endforeach}}
						</ul>
					</td>
					
				</tr>
			</table>
						<!--调用百度编辑器-->
			<table class='table table-bordered'>
				<tr><th colspan="3" class="btn btn-primary bh1">商品详细</th></tr>
				<tr style="display: none;" class="buhidden1">
					<td>
						<!--编辑器-->
							<script id="editor" type="text/plain" style="width:100%;height:200px;" name="gddetail">
								{{$oldgdetail['gddetail']}}
							</script>
						    <script>
						        var ue = UE.getEditor('editor');
					    	</script>
					</td>
				</tr>
				
			</table>
			<table  class='table table-bordered'>
				<tr><th colspan="3" class="btn btn-primary bh2">售后服务</th></tr>
				<tr style="display: none;">
					<td>
						
						<!--编辑器-->
							<script id="editor2" type="text/plain" style="width:100%;height:200px;" name="gdsell">
								{{$oldgdetail['gdsell']}}
							</script>
						    <script>
						        var ue = UE.getEditor('editor2');
					    	</script>
					</td>
				</tr>
				
			</table>
			<!--获得商品的主键-->
			<input type="hidden" name="gid"  value="{{Q('get.gid')}}"/>
			<!--获得商品详细的主键-->
			<input type="hidden" name="gdid" value='{{$oldgdetail['gdid']}}' />
			<input type="hidden" name='tid' value='0'/>
			<input type="submit" value="确认添加" class="btn btn-primary btn-block btn-large" />
		</fieldset>
	</form>

	</div>
	</div>
	</div>
</body>
</html>